package com.usian.controller;

import com.usian.pojo.User;
import com.usian.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private LoginService loginService;

    @RequestMapping("")
    public String index(){
        return "index";
    }

    @RequestMapping("show")
    public String show(String name,String pwd,Model model){
        User user = loginService.login(name, pwd);
        if (user.getId()==1){
            if (user.getQx()==0){
                return "redirect:/product/findAll";
            }else{
                return "redirect:/user/findAll";
            }
        }else{
            model.addAttribute("a",true);
            return "index";
        }
    }
}
